/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.omazan.db.models;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author stryke
 */
@Entity
@Table(name = "LOCATIONS", catalog = "OMAZANDB", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Locations.findAll", query = "SELECT l FROM Locations l"),
    @NamedQuery(name = "Locations.findByLocationId", query = "SELECT l FROM Locations l WHERE l.locationId = :locationId"),
    @NamedQuery(name = "Locations.findByIsActive", query = "SELECT l FROM Locations l WHERE l.isActive = :isActive"),
    @NamedQuery(name = "Locations.findByLatitude", query = "SELECT l FROM Locations l WHERE l.latitude = :latitude"),
    @NamedQuery(name = "Locations.findByLocation", query = "SELECT l FROM Locations l WHERE l.location = :location"),
    @NamedQuery(name = "Locations.findByLongitude", query = "SELECT l FROM Locations l WHERE l.longitude = :longitude")})
public class Locations implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "locationId", nullable = false)
    private Integer locationId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "isActive", nullable = false)
    private boolean isActive;
    @Basic(optional = false)
    @NotNull
    @Column(name = "latitude", nullable = false)
    private float latitude;
    @Size(max = 255)
    @Column(name = "location", length = 255)
    private String location;
    @Basic(optional = false)
    @NotNull
    @Column(name = "longitude", nullable = false)
    private float longitude;
    @OneToMany(mappedBy = "locationId", fetch = FetchType.LAZY)
    private Collection<Shipments> shipmentsCollection;

    public Locations() {
    }

    public Locations(Integer locationId) {
        this.locationId = locationId;
    }

    public Locations(Integer locationId, boolean isActive, float latitude, float longitude) {
        this.locationId = locationId;
        this.isActive = isActive;
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public Integer getLocationId() {
        return locationId;
    }

    public void setLocationId(Integer locationId) {
        this.locationId = locationId;
    }

    public boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(boolean isActive) {
        this.isActive = isActive;
    }

    public float getLatitude() {
        return latitude;
    }

    public void setLatitude(float latitude) {
        this.latitude = latitude;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public float getLongitude() {
        return longitude;
    }

    public void setLongitude(float longitude) {
        this.longitude = longitude;
    }

    @XmlTransient
    public Collection<Shipments> getShipmentsCollection() {
        return shipmentsCollection;
    }

    public void setShipmentsCollection(Collection<Shipments> shipmentsCollection) {
        this.shipmentsCollection = shipmentsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (locationId != null ? locationId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Locations)) {
            return false;
        }
        Locations other = (Locations) object;
        if ((this.locationId == null && other.locationId != null) || (this.locationId != null && !this.locationId.equals(other.locationId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.omazan.entities.Locations[ locationId=" + locationId + " ]";
    }
    
}
